﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="BookList.aspx.cs" Inherits="BookList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Main" runat="Server">
    <asp:Panel ID="Panel1" runat="server" DefaultButton="summit">
        <!--*************************************-->
        <!--Layout******************************-->
        <div class="layout-title">
            <!--Big title********************************-->
            <div class="big">
                <asp:Label ID="Label3" runat="server" CssClass="addpage-toplabel" Text="LIST OF BOOKS"></asp:Label>
            </div>
            <!--*************************************-->
            <asp:Label ID="Label6" runat="server" CssClass="list-category" Text="Search by Category"></asp:Label>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" CssClass="return-dropDownList"
                OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                <asp:ListItem Value=" ">All</asp:ListItem>
                <asp:ListItem>Foreign Literature</asp:ListItem>
                <asp:ListItem>Vietnamese Literature</asp:ListItem>
                <asp:ListItem>English</asp:ListItem>
                <asp:ListItem Value="Information Technology">Information Technology</asp:ListItem>
                <asp:ListItem>Business</asp:ListItem>
            </asp:DropDownList>
            <asp:TextBox ID="search" runat="server" CssClass="return-searchBox" ToolTip="Type Keyword"></asp:TextBox>
            <asp:Button ID="summit" runat="server" CssClass="addpage-button" Text="Search" OnClick="summit_Click" />
        </div>
        <!--*************************************-->
        <!--*************************************-->
        <div class="layout-content">
            <div class="addlast">
            </div>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
                EnableModelValidation="True" DataKeyNames="BookID" DataSourceID="SqlDataSource1"
                OnRowEditing="GridView1_RowEditing" OnRowCommand="GridView1_RowCommand">
                <Columns>
                    <asp:CommandField ShowEditButton="True" />
                    <asp:BoundField DataField="BookName" HeaderText="BookName" SortExpression="BookName" />
                    <asp:BoundField DataField="BookID" HeaderText="BookID" SortExpression="BookID" InsertVisible="False"
                        ReadOnly="True" />
                    <asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
                    <asp:BoundField DataField="Catalogue" HeaderText="Catalogue" SortExpression="Catalogue" />
                    <asp:BoundField DataField="Publisher" HeaderText="Publisher" SortExpression="Publisher" />
                    <asp:BoundField DataField="PublishYear" HeaderText="PublishYear" SortExpression="PublishYear" />
                    
                     
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="DeleteButton" runat="server" CommandName="dele" CommandArgument='<%# Eval("BookID") %>'
                                ImageUrl="Images/Logo.png" />
                            <asp:Label ID="Label1" runat="server" Text="Delete"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Detail">
                        <ItemTemplate>
                            <asp:ImageButton ID="Detail" runat="server" CommandName="detail" CommandArgument='<%# Eval("BookID") %>'
                                ImageUrl="Images/Logo.png" CausesValidation="False" />
                            <asp:Label ID="Label2" runat="server" Text="Detail"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
                ConnectionString="<%$ ConnectionStrings:LMSConnectionString %>" DeleteCommand="DELETE FROM [Books] WHERE [BookID] = @original_BookID AND [BookName] = @original_BookName AND [Author] = @original_Author AND [Catalogue] = @original_Catalogue AND (([Publisher] = @original_Publisher) OR ([Publisher] IS NULL AND @original_Publisher IS NULL)) AND (([PublishYear] = @original_PublishYear) OR ([PublishYear] IS NULL AND @original_PublishYear IS NULL))"
                InsertCommand="INSERT INTO [Books] ([BookName], [Author], [Catalogue], [Publisher], [PublishYear]) VALUES (@BookName, @Author, @Catalogue, @Publisher, @PublishYear)"
                OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [BookName], [BookID], [Author], [Catalogue], [Publisher], [PublishYear] FROM [Books] WHERE (([Catalogue] LIKE '%' + @Catalogue + '%') AND ([BookName] LIKE '%' + @BookName + '%'))"
                UpdateCommand="UPDATE [Books] SET [BookName] = @BookName, [Author] = @Author, [Catalogue] = @Catalogue, [Publisher] = @Publisher, [PublishYear] = @PublishYear WHERE [BookID] = @original_BookID AND [BookName] = @original_BookName AND [Author] = @original_Author AND [Catalogue] = @original_Catalogue AND (([Publisher] = @original_Publisher) OR ([Publisher] IS NULL AND @original_Publisher IS NULL)) AND (([PublishYear] = @original_PublishYear) OR ([PublishYear] IS NULL AND @original_PublishYear IS NULL))">
                <DeleteParameters>
                    <asp:Parameter Name="original_BookID" Type="Int32" />
                    <asp:Parameter Name="original_BookName" Type="String" />
                    <asp:Parameter Name="original_Author" Type="String" />
                    <asp:Parameter Name="original_Catalogue" Type="String" />
                    <asp:Parameter Name="original_Publisher" Type="String" />
                    <asp:Parameter Name="original_PublishYear" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="BookName" Type="String" />
                    <asp:Parameter Name="Author" Type="String" />
                    <asp:Parameter Name="Catalogue" Type="String" />
                    <asp:Parameter Name="Publisher" Type="String" />
                    <asp:Parameter Name="PublishYear" Type="Int32" />
                </InsertParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="DropDownList1" DefaultValue="%%" Name="Catalogue"
                        PropertyName="SelectedValue" Type="String" />
                    <asp:ControlParameter ControlID="search" DefaultValue="%%" Name="BookName" PropertyName="Text"
                        Type="String" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="BookName" Type="String" />
                    <asp:Parameter Name="Author" Type="String" />
                    <asp:Parameter Name="Catalogue" Type="String" />
                    <asp:Parameter Name="Publisher" Type="String" />
                    <asp:Parameter Name="PublishYear" Type="Int32" />
                    <asp:Parameter Name="original_BookID" Type="Int32" />
                    <asp:Parameter Name="original_BookName" Type="String" />
                    <asp:Parameter Name="original_Author" Type="String" />
                    <asp:Parameter Name="original_Catalogue" Type="String" />
                    <asp:Parameter Name="original_Publisher" Type="String" />
                    <asp:Parameter Name="original_PublishYear" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <div class="addlast">
            </div>
        </div>
    </asp:Panel>
</asp:Content>
